#ifndef DEV_IOQUEUE_H
#define DEV_IOQUEUE_H
#include "stdint.h"
#include "sync.h"
#include "thread.h"

#define bufsize 64
struct ioqueue {
    struct lock queue_lock;

    // 记录之前阻塞生产者或消费者
    struct task_struct* producter;
    struct task_struct* consumer;

    char buf[bufsize];
    int32_t head;
    int32_t tail;
};

void ioqueue_init(struct ioqueue* ioq);
bool ioq_full(struct ioqueue* ioq);
bool ioq_empty(struct ioqueue* ioq);
char ioq_getchar(struct ioqueue* ioq);
void ioq_putchar(struct ioqueue* ioq, char ch);
#endif // DEV_IOQUEUE_H